home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / mpeg / mpeg_driver.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  100 lines

  1. /***************************************************************
  2.  *. This file is part of BIT shareware package.
  3.  *
  4.  *  Copyright(c) 1993, 1994 by T.C. Zhao.
  5.  *  All rights reserved.
  6.  *.
  7.  *
  8.  *************************************************************/
  9.  
  10. #include "video.h"
  11. #include "proto.h"
  12. #include <stdlib.h>
  13. #include <sys/types.h>
  14. #include <signal.h>
  15.  
  16. #include "util.h"
  17. #include "dither.h"
  18.  
  19.  
  20. #define BUF_LENGTH 80000    /* Define buffer length. */
  21.  
  22. FILE *input;            /* Global file pointer to incoming data. */
  23. int EOF_flag = 0;        /* End of File flag. */
  24. int loopFlag;            /* Loop flag. */
  25. int quietFlag;            /* Quiet flag. */
  26. int noDisplayFlag;        /* Display image on screen? */
  27. jmp_buf errjmp;
  28. jmp_buf env;
  29. int seek_only;
  30. int ditherType = FULL_COLOR_DITHER;
  31.  
  32. void
  33. frame_re_init(void)
  34. {
  35.     EOF_flag = 0;
  36.     curBits = 0;
  37.     bitOffset = 0;
  38.     bufLength = 0;
  39.     bitBuffer = NULL;
  40. }
  41.  
  42. void
  43. set_mpeg_seek(int y)
  44. {
  45.     seek_only = y;
  46. }
  47.  
  48. void
  49. mpeg_system_init(void)
  50. {
  51.     static mpegsysinit;
  52.  
  53.     if (!mpegsysinit)
  54.       {
  55.  
  56.       LUM_RANGE = 8;
  57.       CR_RANGE = CB_RANGE = 4;
  58.  
  59.       lum_values = (int *) malloc(LUM_RANGE * sizeof(int));
  60.       cr_values = (int *) malloc(CR_RANGE * sizeof(int));
  61.       cb_values = (int *) malloc(CB_RANGE * sizeof(int));
  62.       ditherType = FULL_COLOR_DITHER;
  63.  
  64.       init_tables();
  65.       InitColorDither();
  66.       }
  67.     mpegsysinit = 1;
  68. }
  69.  
  70. void
  71. set_video_stream(FILE * fp)
  72. {
  73.     input = fp;
  74. }
  75.  
  76. static VidStream *theStream;
  77.  
  78. VidStream *
  79. mpeg_next_frame(int n)
  80. {
  81.  
  82.     /** All library error will end up here **/
  83.  
  84.     if (setjmp(errjmp))
  85.       {
  86.       fputs("Bad mpeg stream\n", stderr);
  87.       return 0;
  88.       }
  89.  
  90.     if (n == 0)
  91.       {
  92.       theStream = NewVidStream(BUF_LENGTH);
  93.       mpeg_system_init();
  94.       return mpegVidRsrc(0, theStream);
  95.       }
  96.  
  97.  
  98.     return mpegVidRsrc(0, theStream);
  99. }
  100.